#ifndef BCM_COMPONENT_CNC_COMM_PORT_MANAGER_H
#define BCM_COMPONENT_CNC_COMM_PORT_MANAGER_H

// required interfaces
// (empty)
// provided interfaces
#include "bcmi_dataport.h"
#include "bcmi_taskctl.h"
// generic component
#include "portmgr.h"
// include files
#include <bcm/bcm.h>

//#pragma warning(disable : 4250)

namespace cnc {

namespace comm {

class BCMC_PortManager :
	public bcm::Identifier<bcm::Component>,
	protected bcm::Identifier<BCMI_DataPort>,
	protected bcm::Identifier<cnc::base::BCMI_TaskControl>,
	protected PortManager
{
protected:
	BCMC_PortManager(bcm::GetComponentResult *result) :
		bcm::Identifier<bcm::Component>("portmgr", "Port Manager"),
		bcm::Identifier<BCMI_DataPort>("dataport", "Data Port"),
		bcm::Identifier<cnc::base::BCMI_TaskControl>("taskctl", "Task Control")
	{
		*result = bcm::GC_OK;
	}
	virtual bcm::IdentifierData *getProvidedInterfaceTable()
	{
		static bcm::IdentifierData idData[] = {
			{ "dataport", "Data Port" },
			{ "taskctl", "Task Control" },
			{ nullptr, nullptr }
		};
		return idData;
	}
	virtual bcm::IdentifierData *getRequiredInterfaceTable()
	{
		static bcm::IdentifierData idData[] = {
			{ 0, 0 }
		};
		return idData;
	}
	virtual bcm::Interface *getInterface(const char *id)
	{
		if (std::string("dataport") == id)
			return static_cast<BCMI_DataPort *>(this);
		if (std::string("taskctl") == id)
			return static_cast<cnc::base::BCMI_TaskControl *>(this);
		return nullptr;
	}
	virtual bool setInterface(bcm::Interface *iface)
	{
		if (iface == nullptr)
			return false;
		return false;
	}
public:
	static BCMC_PortManager &instance(bcm::GetComponentResult *result)
	{
		static BCMC_PortManager object(result);
		return object;
	}
};

} // namespace comm

} // namespace cnc

#endif
